package com.lhs.mq;

import com.lhs.mapper.blog_post_0Mapper;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RocketMQMessageListener(topic = "article_publish_topic", consumerGroup = "article-publish-consumer")
public class ArticlePublishConsumer implements RocketMQListener<Long> {

    @Autowired
    private blog_post_0Mapper articleMapper;

    @Override
    public void onMessage(Long articleId) {
        articleMapper.updateStatus(articleId, 1);
        System.out.println("文章ID " + articleId + " 已发布成功");
    }
}
